﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static ConsoleApp.Mapper.MapperExpression;

namespace ConsoleApp.Mapper
{
    public class Student
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }

        public List<StudentItem> StudentItems { get; set; }
    }

 


    public class StudentSecond
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
        public List<StudentItem> StudentItems { get; set; }
    }

    public class StudentItem
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int fenshu { get; set; }
    }
    public class TestMapper
    {
        public static void testReflection() 
        {
            Student s = new Student() { Age = 20, Id = 1, Name = "Emrys", StudentItems =new List<StudentItem>() { 
                new StudentItem{   Id=1, Name="语文",fenshu = 20 },
                new StudentItem{   Id=1, Name="数学",fenshu = 30 },
                new StudentItem{   Id=1, Name="英语",fenshu = 50 }
            } };

            StudentSecond ss = MapperReflection.TransReflection<Student, StudentSecond>(s);
        }
        public static void testExpression()
        {
            Student s = new Student()
            {
                Age = 20,
                Id = 1,
                Name = "小明",
                StudentItems = new List<StudentItem>() {
                new StudentItem{   Id=1, Name="语文1",fenshu = 20 },
                new StudentItem{   Id=1, Name="数学2",fenshu = 30 },
                new StudentItem{   Id=1, Name="英语3",fenshu = 50 }
            }
            };

            StudentSecond ss = TransExpV2<Student, StudentSecond>.Trans(s);
        }
    }
}
